﻿using LPP.Entity;
using System.Threading.Tasks;
using System.Collections.Generic;
using LPP.Entity.Orders;
using Microsoft.EntityFrameworkCore.Storage;
using LPP.Core.Dtos;

namespace LPP.Repository
{
    public interface IOrderRepository
    {
        // 事务相关
        Task<IDbContextTransaction> BeginTransactionAsync();

        // 订单基础操作
        Task<Order> GetOrderByIdAsync(string orderId);
        Task<List<Order>> GetUserOrdersAsync(int userId);
        Task UpdateOrderAsync(Order order);
        Task AddOrderAsync(Order order);

        // 订单明细操作
        Task InsertOrderDetailAsync(OrderDetail orderDetail);
        Task<List<OrderDetail>> GetUnfinishedOrderDetailsAsync();

        // 工人相关查询
        Task<int> GetWorkerPendingOrdersCountAsync(int workerId);
        Task<IEnumerable<Order>> GetWorkerCompletedOrdersAsync(int workerId, DateTime? startDate, DateTime? endDate);

        // 订单状态查询
        Task<IEnumerable<Order>> GetCompletedOrdersAsync(DateTime? startDate, DateTime? endDate);
        Task<int> GetCompletedOrdersCountAsync();  // 新增方法
        Task<WorkerIncomeStatisticsDto> GetWorkerIncomeStatisticsAsync(int workerId);
        Task<PlatformIncomeStatisticsDto> GetPlatformIncomeStatisticsAsync(DateTime? startDate, DateTime? endDate);
        // 分页相关的方法
        Task<IEnumerable<Order>> GetCompletedOrdersAsync(int pageIndex, int pageSize);
        Task<IEnumerable<Order>> GetWorkerCompletedOrdersAsync(int workerId, int pageIndex, int pageSize);
        Task<int> GetWorkerCompletedOrdersCountAsync(int workerId);
        // 账单明细
        Task<(int Total, IEnumerable<OrderBillDto> Bills)> GetWorkerBillsAsync(
            int workerId,
            DateTime? startDate,
            DateTime? endDate,
            int page,
            int pageSize);
    }
}

